from django.db import models
from django.db.models import permalink
from tagging.fields import TagField
from sorl.thumbnail.fields import ImageWithThumbnailsField

class Item(models.Model):
    """
    Something you want.
    """
    
    price       = models.IntegerField()
    image       = ImageWithThumbnailsField(upload_to='img/wishlist/', thumbnail={'size': (100, 100)})
    url         = models.URLField('URL', blank=True, verify_exists=True)
    name        = models.CharField(blank=True, max_length=100)
    description = models.CharField(blank=True, max_length=100)
    tags        = TagField()
    created     = models.DateTimeField(auto_now_add=True)
    updated     = models.DateTimeField(auto_now=True)
    
    class Meta:
       ordering = ('price',)
    
    def __unicode__(self):
        if(self.name):
            return "%s / $%s" % (self.name, self.price)
        else:
            return "$%s" % (self.price)
    
    # @models.permalink
    # def get_absolute_url(self):
    #     return ('item_detail_view_name', [str(self.id)])
